import { memo, useRef, FC } from 'react';
import { Input, Button } from 'antd'
import { TodoListProps } from '../../omd.d'


// 头部控制组件
const ControlInput:FC<TodoListProps> = memo((props) => {
  const { onSubmit } = props;
  const InputDom = useRef();

  return <div>
    <Input ref={InputDom} />  <Button onClick={() => {

      const currentValue = InputDom.current.state.value;
      onSubmit && onSubmit({
        id: Date.now(),
        name: currentValue,
        checked: false,
      })
      InputDom.current.state.value = '';
    }}>提交</Button>
  </div>
})

export default ControlInput;
